import requests
import json
from pyecharts.charts import Map,Geo
from pyecharts import options as opts
from pyecharts.globals import GeoType,RenderType
url='https://api.inews.qq.com/newsqa/v1/automation/foreign/country/ranklist'
headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36'
    }
response=requests.post(url,headers=headers)
response.encoding=response.apparent_encoding
data=response.json()
data_list=data['data']
name_list=[]
confirm_list=[]
for list1 in data_list:
    name=list1['name']
    continent=list1['continent']
    confirm=list1['confirm']
    name_list.append(name)
    confirm_list.append(confirm)
# print(name_list)
# print(confirm_list)
data_list=zip(name_list,confirm_list)
print(list(data_list))
map=Map().add(series_name='世界疫情分布',data_pair=data_list,maptype='world',is_map_symbol_show=False )#输入的数据必须满足要求
map.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
map.set_global_opts(title_opts=opts.TitleOpts(title="国外疫情情况"),visualmap_opts=opts.VisualMapOpts(max_=1000000,is_piecewise=True))
map.render('世界疫情分布情况.html')#保存文本

